package com.ruoyi.web.vehicleownerinfo;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.DsVehicleownerinfo;
import com.ruoyi.service.IDsVehicleownerinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 车辆充卡Controller
 * 
 * @author ruoyi
 * @date 2024-05-24
 */
@RestController
@RequestMapping("/system/vehicleownerinfo")
public class DsVehicleownerinfoController extends BaseController
{
    @Autowired
    private IDsVehicleownerinfoService dsVehicleownerinfoService;

    /**
     * 查询车辆充卡列表
     */
    @PreAuthorize("@ss.hasPermi('system:vehicleownerinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(DsVehicleownerinfo dsVehicleownerinfo)
    {
        startPage();
        List<DsVehicleownerinfo> list = dsVehicleownerinfoService.selectDsVehicleownerinfoList(dsVehicleownerinfo);
        return getDataTable(list);
    }

    /**
     * 导出车辆充卡列表
     */
    @PreAuthorize("@ss.hasPermi('system:vehicleownerinfo:export')")
    @Log(title = "车辆充卡", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DsVehicleownerinfo dsVehicleownerinfo)
    {
        List<DsVehicleownerinfo> list = dsVehicleownerinfoService.selectDsVehicleownerinfoList(dsVehicleownerinfo);
        ExcelUtil<DsVehicleownerinfo> util = new ExcelUtil<DsVehicleownerinfo>(DsVehicleownerinfo.class);
        util.exportExcel(response, list, "车辆充卡数据");
    }

    /**
     * 获取车辆充卡详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:vehicleownerinfo:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(dsVehicleownerinfoService.selectDsVehicleownerinfoByUserId(userId));
    }

    /**
     * 新增车辆充卡
     */
    @PreAuthorize("@ss.hasPermi('system:vehicleownerinfo:add')")
    @Log(title = "车辆充卡", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DsVehicleownerinfo dsVehicleownerinfo)
    {
        return toAjax(dsVehicleownerinfoService.insertDsVehicleownerinfo(dsVehicleownerinfo));
    }

    /**
     * 修改车辆充卡
     */
    @PreAuthorize("@ss.hasPermi('system:vehicleownerinfo:edit')")
    @Log(title = "车辆充卡", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DsVehicleownerinfo dsVehicleownerinfo)
    {
        return toAjax(dsVehicleownerinfoService.updateDsVehicleownerinfo(dsVehicleownerinfo));
    }

    /**
     * 删除车辆充卡
     */
    @PreAuthorize("@ss.hasPermi('system:vehicleownerinfo:remove')")
    @Log(title = "车辆充卡", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(dsVehicleownerinfoService.deleteDsVehicleownerinfoByUserIds(userIds));
    }
}
